//
//  Solution.h
//  leetcode
//
//  Created by hellobike07499 on 2019/8/30.
//  Copyright © 2019 hellobike07499. All rights reserved.
//

#ifndef Solution_h
#define Solution_h
#include <vector>
#include <random>
#include <iostream>

using namespace std;

class Solution{
    
public:
    static void test(){
        vector<int> t = {1, 2, 3, 4, 5, 6};
        Solution ss(t);
        
        vector<int> t1 = ss.shuffle();
        cout << ""<< endl;
    }
    
public:
    Solution(vector<int>& nums):mNums(nums) {
        
    }
    
    /** Resets the array to its original configuration and return it. */
    vector<int> reset() {
        return mNums;
    }
    
    /** Returns a random shuffling of the array. */
    vector<int> shuffle() {
        default_random_engine engin;
        uniform_int_distribution<> dis(0, (int)mNums.size() - 1);
        
        vector<int> result(mNums);
        for (int i = 0; i < mNums.size(); i++) {
            int dest = dis(engin);
            int tmp = result[i];
            result[i] = result[dest];
            result[dest] = tmp;
        }
        return result;
    }
    
private:
    vector<int> mNums;
};

#endif /* Solution_h */
